#!/bin/sh
echo "use fangfa"
echo "./createKvm.sh xxxxx /home/img/xxxxxx.img"
if [ $# -lt 2 ];then
 echo "please canshu > 2!"
	exit
fi

if [ -f $2 ];then
uuid=`uuidgen`
sourStr="/home/centos-img/centos75-soc.img"
cp generic.xml /etc/libvirt/qemu/$1.xml
sed -i 's/generic/'"$1"'/g'  /etc/libvirt/qemu/$1.xml
sed -i 's/c2529032-4ffa-4896-a2ac-71fa49fadf7e/'"$uuid"'/g'  /etc/libvirt/qemu/$1.xml
sed -i 's#'''$sourStr'''#'"$2"'#g'  /etc/libvirt/qemu/$1.xml
virsh define /etc/libvirt/qemu/$1.xml
virsh start $1
else
  
   echo "img file is not exist!"
   sh copyimg.sh $2
fi

